package com.bjb.vr.client.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * canal-rabbitmq本地配置
 * @version 1.0.0
 * @author: HuJingBo
 * @time: 2022/6/24 16:17
 */
@Configuration
public class CanalConfig {

    public static final String QUEUE_INFO_CANAL = "dataSyncQueue";
    public static final String EXCHANGE_INFO_CANAL = "canal.exchange";
    public static final String EXCHANGE_QUEUE_KEY = "canal.routing.key";

    @Bean
    Queue clientQueue() {
        return new Queue(QUEUE_INFO_CANAL);
    }

    @Bean
    DirectExchange clientExchange() {
        return new DirectExchange(EXCHANGE_INFO_CANAL);
    }

    @Bean
    Binding clientBinding() {
        return BindingBuilder.bind(clientQueue()).to(clientExchange()).with(EXCHANGE_QUEUE_KEY);
    }
}
